<!-- 我的爱车 页面-->
<include file='Common:head'/>
<div class="add_car">
	<div class="add_img fl"><img src="__PRIVATE__/images/add.png"/></div>
	<div class="add_title fl">我的愛車</div>
	<div class="right fr"><img src="__PRIVATE__/images/right.png" style="width:20%;"/></div>
	<div class="cl"></div>
</div>
<div class="have_car_num">已添加愛車&nbsp;<span>{$carcount}</span>&nbsp;輛</div>
<div class="car_list box2">
	<foreach name="user" item="vo" >
		<div class="car_info">
			<!-- <div class="car_logo fl"><img src="__PRIVATE__/images/BMW.png"/></div> -->
			<div class="car_logo fl"><img src="__PRIVATE__/images/lovecar.png"/></div>
			<div class="car_num"><num>{$vo.license_plate}</num>
				<if condition="($vo.default eq '1')">
					<span>默認</span>
				</if>
			</div>
			<div class="car_brand">
				{$vo.brand}
				<switch name="vo.type">
                    <case value="1">五座車</case>
                    <case value="2">七座車</case>
                    <case value="3">其他車</case>
                </switch>
			</div>
				<if condition="($vo.default eq '0')">
					<set class="fr"><a href="javascript:setDefaultCar({$vo.id});">設為默認</a></set>
					<set class="fr"><a href="javascript:delLoveCar({$vo.id});">删除爱车</a></set>
				</if>
			<div class="cl"></div>
		</div>
	</foreach>

</div>
<script type="text/javascript">
$('title').html('個人中心');
$('.header .title').html('我的愛車');
$('.header .left').html('<img src="__PRIVATE__/images/left.png" style="width:55%"/>');
$('.header .right').html('');

// 【添加】我的爱车
$('.add_car').click(function(){
	window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/addmycarview')}";
});

// 【返回】上一页面
$('.header .left').click(function(){
	window.location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/my')}";
});

//設為默認
function setDefaultCar(id){
	var savePostData = {id:id};
	$.post("{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/setDefaultCar')}",savePostData,function(data){
		if (data.status) {
			if (data.status==1) {
				layer.open({
				    content: data.info
				    ,skin: 'msg'
				    ,style: 'width: 30%; height:5%;padding:20px;font-size:3rem;'
				    ,time: 1 //2秒后自动关闭
				    ,end: function () {
						location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/"+data.url+"')}";
					}
				});
	        }else{
				location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/"+data.url+"')}";
	        }
		}
	});
}
//删除爱车
function delLoveCar(id){
	var savePostData = {id:id};
	$.post("{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/delLoveCar')}",savePostData,function(data){
		if (data.status) {
			if (data.status==1) {
				layer.open({
				    content: data.info
				    ,skin: 'msg'
				    ,style: 'width: 30%; height:5%;padding:20px;font-size:3rem;'
				    ,time: 1 //2秒后自动关闭
				    ,end: function () {
						location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/"+data.url+"')}";
					}
				});
	        }else{
				location.href = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/"+data.url+"')}";
	        }
		}
	});
}
</script>
<include file='Common:footer'/>
